/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package cz.vutbr.fit.xzemko01.tfmcbs.model.impl;

import cz.vutbr.fit.xzemko01.tfmcbs.model.Provider;
import cz.vutbr.fit.xzemko01.tfmcbs.model.Realization;
import cz.vutbr.fit.xzemko01.tfmcbs.model.Requier;
import cz.vutbr.fit.xzemko01.tfmcbs.model.SimpleComponent;
import cz.vutbr.fit.xzemko01.tfmcbs.model.Usage;

import cz.vutbr.fit.xzemko01.tfmcbs.model.meta.TfmcbsPackage;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Simple Component</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link cz.vutbr.fit.xzemko01.tfmcbs.model.impl.SimpleComponentImpl#getRealizations <em>Realizations</em>}</li>
 *   <li>{@link cz.vutbr.fit.xzemko01.tfmcbs.model.impl.SimpleComponentImpl#getUsages <em>Usages</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SimpleComponentImpl extends ComponentImpl implements SimpleComponent {
	/**
	 * The cached value of the '{@link #getRealizations() <em>Realizations</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRealizations()
	 * @generated
	 * @ordered
	 */
	protected EList<Realization> realizations;

	/**
	 * The cached value of the '{@link #getUsages() <em>Usages</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUsages()
	 * @generated
	 * @ordered
	 */
	protected EList<Usage> usages;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SimpleComponentImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return TfmcbsPackage.Literals.SIMPLE_COMPONENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Realization> getRealizations() {
		if (realizations == null) {
			realizations = new EObjectWithInverseResolvingEList<Realization>(Realization.class, this, TfmcbsPackage.SIMPLE_COMPONENT__REALIZATIONS, TfmcbsPackage.REALIZATION__PROVIDER);
		}
		return realizations;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Usage> getUsages() {
		if (usages == null) {
			usages = new EObjectWithInverseResolvingEList<Usage>(Usage.class, this, TfmcbsPackage.SIMPLE_COMPONENT__USAGES, TfmcbsPackage.USAGE__REQUIER);
		}
		return usages;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TfmcbsPackage.SIMPLE_COMPONENT__REALIZATIONS:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getRealizations()).basicAdd(otherEnd, msgs);
			case TfmcbsPackage.SIMPLE_COMPONENT__USAGES:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getUsages()).basicAdd(otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TfmcbsPackage.SIMPLE_COMPONENT__REALIZATIONS:
				return ((InternalEList<?>)getRealizations()).basicRemove(otherEnd, msgs);
			case TfmcbsPackage.SIMPLE_COMPONENT__USAGES:
				return ((InternalEList<?>)getUsages()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case TfmcbsPackage.SIMPLE_COMPONENT__REALIZATIONS:
				return getRealizations();
			case TfmcbsPackage.SIMPLE_COMPONENT__USAGES:
				return getUsages();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case TfmcbsPackage.SIMPLE_COMPONENT__REALIZATIONS:
				getRealizations().clear();
				getRealizations().addAll((Collection<? extends Realization>)newValue);
				return;
			case TfmcbsPackage.SIMPLE_COMPONENT__USAGES:
				getUsages().clear();
				getUsages().addAll((Collection<? extends Usage>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case TfmcbsPackage.SIMPLE_COMPONENT__REALIZATIONS:
				getRealizations().clear();
				return;
			case TfmcbsPackage.SIMPLE_COMPONENT__USAGES:
				getUsages().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case TfmcbsPackage.SIMPLE_COMPONENT__REALIZATIONS:
				return realizations != null && !realizations.isEmpty();
			case TfmcbsPackage.SIMPLE_COMPONENT__USAGES:
				return usages != null && !usages.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
		if (baseClass == Provider.class) {
			switch (derivedFeatureID) {
				case TfmcbsPackage.SIMPLE_COMPONENT__REALIZATIONS: return TfmcbsPackage.PROVIDER__REALIZATIONS;
				default: return -1;
			}
		}
		if (baseClass == Requier.class) {
			switch (derivedFeatureID) {
				case TfmcbsPackage.SIMPLE_COMPONENT__USAGES: return TfmcbsPackage.REQUIER__USAGES;
				default: return -1;
			}
		}
		return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) {
		if (baseClass == Provider.class) {
			switch (baseFeatureID) {
				case TfmcbsPackage.PROVIDER__REALIZATIONS: return TfmcbsPackage.SIMPLE_COMPONENT__REALIZATIONS;
				default: return -1;
			}
		}
		if (baseClass == Requier.class) {
			switch (baseFeatureID) {
				case TfmcbsPackage.REQUIER__USAGES: return TfmcbsPackage.SIMPLE_COMPONENT__USAGES;
				default: return -1;
			}
		}
		return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
	}

} //SimpleComponentImpl
